import type { RouteObject } from 'react-router-dom'
import { Navigate } from 'react-router-dom'
import Home from '../pages/Home'
import Circle from '../pages/Circle'
import Around from '../pages/Around'
import Mine from '../pages/Mine'
import Login from '../pages/Login'
import GetCode from '../pages/GetCode'
import { lazy, Suspense } from 'react'
import Category from '../pages/Category'

const Search = lazy(() => import('../pages/Search'))
const VideoPlay = lazy(() => import('../pages/VideoPlayDetail'))
const CircleDetail = lazy(() => import('../pages/CircleDetail'))
const SetUserInfo = lazy(() => import('../pages/SetUserInfo/'))
const UserInfo = lazy(() => import('../pages/Mine/UserInfo'))
const AddressList = lazy(() => import('../pages/Mine/UserAddress'))
const AddAddress = lazy(() => import('../pages/Mine/AddAddress'))
const CategoryDetail = lazy(() => import('../pages/CategoryDetail'))
const Store = lazy(() => import('../pages/Store'))
const routes: Array<RouteObject> = [
  {
    // 首页
    path: '/home',
    element: <Home />
  },
  {
    // 周边
    path: '/around',
    element: <Around />
  },
  {
    // 逛逛
    path: '/circle',
    element: <Circle />
  },
  {
    // 我的
    path: '/mine',
    element: <Mine />
  },
  {
    // 登录
    path: '/login',
    element: <Login />
  },
  {
    // 搜索
    path: '/search',
    element: (
      <Suspense>
        <Search />
      </Suspense>
    )
  },
  {
    // 获取验证码
    path: '/sendcode',
    element: <GetCode />
  },

  {
    // 逛逛页面点击之后详情页面
    path: '/circleget',
    element: (
      <Suspense>
        <CircleDetail />
      </Suspense>
    )
  },
  {
    // 用户信息设置
    path: '/setting',
    element: (
      <Suspense>
        <SetUserInfo />
      </Suspense>
    )
  },
  {
    // 修改个人信息
    path: '/update',
    element: (
      <Suspense>
        <UserInfo />
      </Suspense>
    )
  },
  {
    //地址页面
    path: '/address/get',
    element: (
      <Suspense>
        <AddressList />
      </Suspense>
    )
  },
  {
    //新增地址
    path: '/address/add',
    element: (
      <Suspense>
        <AddAddress />
      </Suspense>
    )
  },
  {
    // 首页分类数据页面路由规则
    path: '/category',
    element: (
      <Suspense>
        <Category />
      </Suspense>
    )
  },
  {
    //视频播放页面
    path: '/video',
    element: (
      <Suspense>
        <VideoPlay />
      </Suspense>
    )
  },
  {
    // category详情页
    path: '/detail',
    element: (
      <Suspense>
        <CategoryDetail />
      </Suspense>
    )
  },
  {
    path: '/store',
    element: (
      <Suspense>
        <Store />
      </Suspense>
    )
  },
  //当访问的是/时跳转到/home
  {
    path: '/',
    element: <Navigate to="/home" />
  }
]

export default routes
